
<{if $point_sale->ID != null && $point_sale->ID != "" && $point_sale->ID != 0}>
    <{assign var=isEditForm value=true }>
<{else}>
    <{assign var=isEditForm value=false }>
<{/if}>

<link type="text/css" rel="stylesheet" href="<{$smarty.const.APPLICATION_IMAGE_URL}>/country/country_phone.css"/>
<script type="text/javascript" src="<{$smarty.const.APPLICATION_SCRIPT_LIB_URL}>/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<{$smarty.const.GOOGLE_MAP_API_SERVICE}>"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
    //Set language
    LanguageConst._MSG_POINT_SALE_NOT_EMPTY = "<{#_MSG_POINT_SALE_NOT_EMPTY#|utf8_escape_js}>";
    LanguageConst._MSG_STREET_NOT_EMPTY = "<{#_MSG_STREET_NOT_EMPTY#|utf8_escape_js}>";
    LanguageConst._MSG_INVALID_EMAIL = "<{#_MSG_INVALID_EMAIL#|utf8_escape_js}>";
    LanguageConst._MSG_INVALID_POSITION = "<{#_MSG_INVALID_POSITION#|utf8_escape_js}>";
    LanguageConst._MSG_INVALID_PHONE = "<{#_MSG_INVALID_PHONE#|utf8_escape_js}>";
    LanguageConst._MSG_CITY_NOT_EXIST = "<{#_MSG_CITY_NOT_EXIST#|utf8_escape_js}>";
    LanguageConst._MSG_COUNTRY_NOT_EXIST = "<{#_MSG_COUNTRY_NOT_EXIST#|utf8_escape_js}>";
    LanguageConst._MSG_SUPPLIER_NOT_EXIST = "<{#_MSG_SUPPLIER_NOT_EXIST#|utf8_escape_js}>";
    LanguageConst._MSG_TERM_NOT_CHECKED = "<{#_MSG_TERM_NOT_CHECKED#|utf8_escape_js}>";
    LanguageConst._MSG_IMAGE_VERIFICATION_NOT_EMPTY = "<{#_MSG_IMAGE_VERIFICATION_NOT_EMPTY#|utf8_escape_js}>";
    LanguageConst._MSG_IMAGE_VERIFICATION_NOT_MATCH = "<{#_MSG_IMAGE_VERIFICATION_NOT_MATCH#|utf8_escape_js}>"
    LanguageConst._MSG_OVER_MAX_LENGTH_ALLOW = "<{#_MSG_OVER_MAX_LENGTH_ALLOW#|utf8_escape_js}>";
    LanguageConst._MSG_POINT_SALE_NAME_OVER_MAX_LENGTH_ALLOW = "<{#_MSG_POINT_SALE_NAME_OVER_MAX_LENGTH_ALLOW#|utf8_escape_js|replace:'[#MAX_LENGTH#]':$smarty.const.MAX_LENGTH_POINT_SALE_NAME}>";
    LanguageConst._MSG_STREET_OVER_MAX_LENGTH_ALLOW = "<{#_MSG_STREET_OVER_MAX_LENGTH_ALLOW#|utf8_escape_js|replace:'[#MAX_LENGTH#]':$smarty.const.MAX_LENGTH_LOCATION_ADDRESS}>";
    LanguageConst._MSG_PHONE_NUMBER_OVER_MAX_LENGTH_ALLOW =  "<{#_MSG_PHONE_NUMBER_OVER_MAX_LENGTH_ALLOW#|utf8_escape_js|replace:'[#MAX_LENGTH#]':$smarty.const.MAX_LENGTH_EMAIL}>";
    LanguageConst._MSG_EMAIL_OVER_MAX_LENGTH_ALLOW = "<{#_MSG_EMAIL_NUMBER_OVER_MAX_LENGTH_ALLOW#|utf8_escape_js|replace:'[#MAX_LENGTH#]':$smarty.const.MAX_LENGTH_PHONE_NUMBER}>";
    
    
    LanguageConst._LB_NAME = "<{#_LB_NAME#|utf8_escape_js}>";
    LanguageConst._LB_ADDRESS = "<{#_LB_ADDRESS#|utf8_escape_js}>";
    LanguageConst._LB_EMAIL = "<{#_LB_EMAIL#|utf8_escape_js}>";
    LanguageConst._LB_PHONE = "<{#_LB_PHONE#|utf8_escape_js}>";
    
    //Set Const
    Const.MAX_LENGTH_POINT_SALE_NAME = "<{$smarty.const.MAX_LENGTH_POINT_SALE_NAME|utf8_escape_js}>";
    Const.MAX_LENGTH_LOCATION_ADDRESS = "<{$smarty.const.MAX_LENGTH_LOCATION_ADDRESS|utf8_escape_js}>";
    Const.MAX_LENGTH_EMAIL = "<{$smarty.const.MAX_LENGTH_EMAIL|utf8_escape_js}>";
    Const.MAX_LENGTH_PHONE_NUMBER = "<{$smarty.const.MAX_LENGTH_PHONE_NUMBER|utf8_escape_js}>";
    
    <{foreach  from=$_ERROR_CODE item=error }>
        ErrorMessage["<{$error|utf8_escape_js}>"] = LanguageConst.<{$error|utf8_escape_js}>;
    <{/foreach}>
    
    //Set map
    google.setOnLoadCallback(Map.initMap);
    PointSale.cityId = '<{$point_sale->CITY_ID}>';
    
    <{if isset($point_sale) }>
        CurrentPosition.lat = '<{$point_sale->X}>';
        CurrentPosition.lng = '<{$point_sale->Y}>';
    <{/if}>
    
    <{if $isEditForm }>
        isImageVerificationSkipped = true;
        isTermSkipped = true;
    <{/if}>
</script>
<div class="point_sale_form" id="point_sale_form">
    <div class="tab">
        <div class="item homepage" onclick="location.href='<{$_CONTEXT_PATH}>/homepage'">
                &nbsp;
        </div>
        <div class="separate"></div>
        <div class="item">
            <{#_LB_PRODUCT_HOME#|utf8_escape_html}>
        </div>
        <div class="separate"></div>
        <div class="item" onclick="location.href='<{$_CONTEXT_PATH}>/point-sale'" >
            <{#_LB_POINT_SALE_LIST#|utf8_escape_html}>
        </div>
        <div class="item menu">
                &nbsp;
        </div>
    </div>
    
    <form
        <{if $isEditForm }>
            action="<{$_CONTEXT_PATH}>/point-sale-form/editPointSale?id=<{$point_sale->ID|utf8_escape_html}>" 
        <{else}>
            action="<{$_CONTEXT_PATH}>/point-sale-form/addPointSale" 
        <{/if}>
        name="point_sale_form" id="point_sale_form"  
        onsubmit="return validatePointSaleForm(this)"
        method="post">
        <h3>
            <{if $isEditForm }>
                <{#_LB_EDIT_POINT_SALE#|utf8_escape_html}>
            <{else}>
                <{#_LB_ADD_POINT_SALE#|utf8_escape_html}>
            <{/if}>
        </h3>
        <input type="hidden" name="position" id="position"/>
        <table>
            <tr>
                <th><{#_LB_NAME#|utf8_escape_html}> <font class="required_field"><{#_LB_REQUIRED_FIELD#}></font></th>
            </tr>
            <tr>
                <td>
                    <input type="text" class="textbox" value="<{$point_sale->NAME|utf8_escape_html}>" name="point_sale_name" id="point_sale_name"/>
                </td>
            </tr>
            <tr>
                <th><{#_LB_COUNTRY#|utf8_escape_html}> <font class="required_field"><{#_LB_REQUIRED_FIELD#}></font></th>
            </tr>
            <tr>
                <td>
                    <select onchange="loadCity()"  name="country" class="combobox" id="country">
                        <{while $country->fetch()}>
                            <option <{if $country->ID == $point_sale->COUNTRY_ID}>selected<{/if}> value="<{$country->ID}>"><{$country->NAME|utf8_escape_html}></option>
                        <{/while}>
                    </select>
                </td>
            </tr>
            <tr>
                <th><{#_LB_CITY#|utf8_escape_html}> <font class="required_field"><{#_LB_REQUIRED_FIELD#}></font></th>
            </tr>
            <tr>
                <td>
                    <select name="city" class="combobox" id="city"></select>
                </td>
            </tr>
            <tr>
                <th>
                    <{#_LB_ADDRESS#|utf8_escape_html}> 
                    <font class="required_field"><{#_LB_REQUIRED_FIELD#}></font> 
                </th>
            </tr>
            <tr>
                <td>
                    <div class="address_textbox">
                        <input type="text" class="textbox" value="<{$point_sale->STREET|utf8_escape_html}>" name="address" id="address" onblur="locationAddress()"/>
                        <span class="location_map" onclick="locationAddress()"></span>
                    </div>
                </td>
            </tr>
            <tr>
                <th><{#_LB_EMAIL#|utf8_escape_html}></th>
            </tr>
            <tr>
                <td>
                    <input type="text" value="<{$point_sale->EMAIL|utf8_escape_html}>" class="textbox" name="email" id="email"/>
                </td>
            </tr>
            <tr>
                <th><{#_LB_PHONE#|utf8_escape_html}></th>
            </tr>
            <tr>
                <td class="country_phone">
                    <{assign var=phones value="."|explode:$point_sale->PHONE }>
                    <div class="phone_code_container">
                        <span id="phone_code_symbol"></span>
                        <select onchange="loadPhoneCode()" id="phone_code" name="phone_code" class="combobox">
                            <{foreach from=$country_phone key=key item=code}>
                            <option <{if $phones.0 == $key}>selected<{/if}> value="<{$key|utf8_escape_html}>"><{$code|utf8_escape_html}></option>
                            <{/foreach}>
                        </select>  
                    </div>
                    <input type="text" value="<{$phones.1|utf8_escape_html}>" class="textbox" name="phone" id="phone"/>
                </td>
            </tr>
            <tr>
                <th><{#_LB_OTHER_INFORMATION#|utf8_escape_html}></th>
            </tr>
            <tr>
                <td>
                    <textarea id="other_information" name="other_information" class="textbox"><{$point_sale->OTHER_INFORMATION|utf8_escape_textarea}></textarea>
                </td>
            </tr>
            <{if !$isEditForm }>
            <tr>
                <th class="captcha_header"><{#_LB_CAPTCHA#|utf8_escape_html}> <font class="required_field"><{#_LB_REQUIRED_FIELD#}></font></th>
            </tr>
            <tr>
                <td class="captcha_footer">
                    <div class="image_verification">
                        <img src="<{$temp_captcha_url|utf8_escape_html}>" id="image_verification" alt="<{$temp_captcha|utf8_escape_html}>"/>
                    </div>
                    <{#_LB_CAPTCHA_DESCRIPTION#|utf8_escape_html}>: 
                    <input type="hidden" class="textbox" name="temp_captcha" id="temp_captcha" value="<{$temp_captcha|utf8_escape_html}>"/>
                    <input type="text" class="textbox" name="captcha" id="captcha"/> 
                    <span class="refresh_captcha" onclick="refreshCaptcha()"></span>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="checkbox_term"> <input type="checkbox" value="false" class="checkbox" name="is_term" id="is_term"/> </div>
                    <div class="term_desc"><{#_LB_USE_TERM#}></div>
                </td>
            </tr>
            <{/if}>
            <tr>
                <td>
                    <div  class="error_message" id="error_message"></div>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" class="button"  value="<{#_LB_SUBMIT#|utf8_escape_html}>"/>
                </td>
            </tr>
        </table>
    </form>
</div>
<div class="region_container">
    <div class="region" id="region">
        <div class="map" id="map"></div>
    </div>
</div>